/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Rohit
 */
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

public class MainGui extends javax.swing.JFrame {

    public Connection connection = null;
    public DefaultTableModel tableModel;
    /**
     * Creates new form MainGui
     */
    public MainGui() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel15 = new javax.swing.JPanel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jTextField21 = new javax.swing.JTextField();
        jTextField22 = new javax.swing.JTextField();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jTextField6 = new javax.swing.JTextField();
        jPanel16 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jTextField17 = new javax.swing.JTextField();
        jTextField18 = new javax.swing.JTextField();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jPanel6 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel20 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTable7 = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jPanel17 = new javax.swing.JPanel();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jTextField23 = new javax.swing.JTextField();
        jTextField24 = new javax.swing.JTextField();
        jButton17 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jTextField7 = new javax.swing.JTextField();
        jPanel18 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable4 = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTabbedPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Demonstrator"));

        jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder("Input Box"));

        jLabel27.setText("Enter the configuration");

        jLabel28.setText("Duration of Test (In Seconds)");

        jLabel29.setText("Number of Clients");

        jButton15.setText("Run");

        jButton16.setText("Cancel");

        jLabel7.setText("Number of Warehouses");

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel29, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                .addComponent(jButton15, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(9, 9, 9))
                            .addComponent(jLabel28, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                                .addComponent(jButton16, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(63, 63, 63))
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                .addGap(38, 38, 38)
                                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField22, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jTextField21)
                                    .addComponent(jTextField6)))))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jLabel27)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(22, 22, 22))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel27)
                .addGap(23, 23, 23)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel28))
                .addGap(18, 18, 18)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel29, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton15)
                    .addComponent(jButton16))
                .addContainerGap())
        );

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder("Output Box"));

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 392, Short.MAX_VALUE)
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Description"));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        jTabbedPane1.addTab("TPC-C Benchmark", jPanel1);

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder("Input Box"));

        jLabel21.setText("Enter the configuration");

        jLabel23.setText("Number of Versions");

        jLabel24.setText("Number of Reading Tx");

        jButton11.setText("Run");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jButton12.setText("Cancel");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jLabel5.setText("Number of Inserts");

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel24, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(9, 9, 9))
                            .addComponent(jLabel23, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                                .addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(63, 63, 63))
                            .addGroup(jPanel11Layout.createSequentialGroup()
                                .addGap(38, 38, 38)
                                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField18, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jTextField17)
                                    .addComponent(jTextField4)))))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addComponent(jLabel21)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(22, 22, 22))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel21)
                .addGap(23, 23, 23)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23))
                .addGap(18, 18, 18)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton11)
                    .addComponent(jButton12))
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Description"));

        jLabel1.setText("1. This benchmark supports long version chains of data item. This workload is update centric.");

        jLabel2.setText("2. This benchmark focus on reading latest data from a database.");

        jLabel3.setText("3. Higher management overhead due to update centric load.");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addContainerGap(432, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addComponent(jLabel3)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        jPanel20.setBorder(javax.swing.BorderFactory.createTitledBorder("Output Box"));

        jTable7.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Total Exec. Time", null, null, null},
                {"Insertion Time", null, null, null},
                {"Updating Time", null, null, null},
                {"Avg. Reading Time", null, null, null}
            },
            new String [] {
                "Result", "Postgresql", "MVIDX", "Improvement( In %)"
            }
        ));
        jScrollPane7.setViewportView(jTable7);

        javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20);
        jPanel20.setLayout(jPanel20Layout);
        jPanel20Layout.setHorizontalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7)
                .addContainerGap())
        );
        jPanel20Layout.setVerticalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("MicroBenchmark I - ", jPanel2);

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder("Input Box"));

        jLabel30.setText("Enter the configuration");

        jLabel31.setText("Number of Versions");

        jLabel32.setText("Number of Reading Tx");

        jButton17.setText("Run");
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });

        jButton18.setText("Cancel");

        jLabel12.setText("Number of Inserts");

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel32, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                            .addGroup(jPanel17Layout.createSequentialGroup()
                                .addComponent(jButton17, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(9, 9, 9))
                            .addComponent(jLabel31, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel17Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                                .addComponent(jButton18, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(63, 63, 63))
                            .addGroup(jPanel17Layout.createSequentialGroup()
                                .addGap(38, 38, 38)
                                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextField24, javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jTextField23)
                                    .addComponent(jTextField7)))))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel30)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(22, 22, 22))
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel30)
                .addGap(23, 23, 23)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addGap(18, 18, 18)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel31))
                .addGap(18, 18, 18)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel32, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton17)
                    .addComponent(jButton18))
                .addContainerGap())
        );

        jPanel18.setBorder(javax.swing.BorderFactory.createTitledBorder("Output Box"));
        jPanel18.setFocusTraversalPolicyProvider(true);

        jTable4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Total Exec. Time", null, null, null},
                {"Insertion Time", "", null, null},
                {"Updating Time", null, null, null},
                {"Avg. Reading Time", null, null, null}
            },
            new String [] {
                "Results", "Postgresql", "MVIDX", "Improvement ( In %)"
            }
        ));
        jScrollPane4.setViewportView(jTable4);

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4)
                .addContainerGap())
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Description"));

        jLabel4.setText("2. Many visible versions in the database.");

        jLabel6.setText("1. Focus on parallelism of number of user.");

        jLabel8.setText("3. Mixed load with short and long reading transactions.");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel4)
                    .addComponent(jLabel8))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addGap(18, 18, 18)
                .addComponent(jLabel8)
                .addContainerGap(21, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(6, 6, 6)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("MicroBenchmark - II", jPanel3);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 919, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 433, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Demo Videos", jPanel4);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed

        inputInsert= Integer.parseInt(jTextField4.getText());
        inputNoOfVersions=Integer.parseInt(jTextField17.getText());
        inputNoOfRdTx=Integer.parseInt(jTextField18.getText());
        Thread Tinsert, Tupdate,Tread;
        startTotalTime=System.currentTimeMillis();
        MainGui mainGui=new MainGui();
        mainGui.establishConnection();
        startInsertingTime=System.currentTimeMillis();
//        Tinsert=new Thread(new InsertThread2(1, inputInsert,connection));
//        Tinsert.start();
//        try {
//            Tinsert.join();
//        } catch (InterruptedException ex) {
//            Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//        }
        mainGui.insertDataMBI(2, inputInsert);
        stopInsertingTime=System.currentTimeMillis();
        startUpdatingTime=System.currentTimeMillis();
//        for(int i=1;i<inputNoOfVersions;i++)
//        {
//            try {
//                Tupdate = new Thread(new UpdateThread1(1,inputInsert,connection));
//                Tupdate.start();
//                Tupdate.join();
//            } catch (InterruptedException ex) {
//                Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//            }
//        }
        for(int i=1;i<inputNoOfVersions;i++){
            mainGui.updateDataMBI(2, inputInsert);
        }
        
        stopUpdatingTime=System.currentTimeMillis();
        startReadingTime=System.currentTimeMillis();
        for(int i=1;i<inputNoOfRdTx;i++)
        {
            mainGui.selectData(3, inputInsert, connection);
//            try {
//                Tread = new Thread(new ReadingThread(3, inputInsert -1, connection));
//                Tread.start();
//                Tread.join();
//            } catch (InterruptedException ex) {
//                Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//            }
        }
        
        stopReadingTime=System.currentTimeMillis();
        stopTotalTime = System.currentTimeMillis();
        elapsedInsertingTime=stopInsertingTime-startInsertingTime;
        elapsedReadingTime=(stopReadingTime-startReadingTime)/inputNoOfRdTx;
        elapsedUpdatingTime=(stopUpdatingTime-startUpdatingTime)/inputNoOfVersions;
        elapsedTotalTime = stopTotalTime - startTotalTime;
        System.out.println("Total Execution time is "+ elapsedTotalTime);
        jTable7.getModel().setValueAt(Long.toString(elapsedTotalTime), 0, 1);
        jTable7.getModel().setValueAt(Long.toString(elapsedInsertingTime), 1, 1);
        jTable7.getModel().setValueAt(Long.toString(elapsedUpdatingTime), 2, 1);
        jTable7.getModel().setValueAt(Long.toString(elapsedReadingTime), 3, 1);
        
        //mvidx code for display testing
        
        mvstartTotalTime=System.currentTimeMillis();
        mainGui.establishConnection();
        mvstartInsertingTime=System.currentTimeMillis();
//        Tinsert=new Thread(new InsertThread2(1, inputInsert,connection));
//        Tinsert.start();
//        try {
//            Tinsert.join();
//        } catch (InterruptedException ex) {
//            Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//        }
        mainGui.insertDataMBI(2, inputInsert);
        mvstopInsertingTime=System.currentTimeMillis();
        mvstartUpdatingTime=System.currentTimeMillis();
//        for(int i=1;i<inputNoOfVersions;i++)
//        {
//            try {
//                Tupdate = new Thread(new UpdateThread1(1,inputInsert,connection));
//                Tupdate.start();
//                Tupdate.join();
//            } catch (InterruptedException ex) {
//                Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//            }
//        }
        for(int i=1;i<inputNoOfVersions;i++){
            mainGui.updateDataMBI(2, inputInsert);
        }        
        mvstopUpdatingTime=System.currentTimeMillis();
        mvstartReadingTime=System.currentTimeMillis();
        for(int i=1;i<inputNoOfRdTx;i++)
        {
            mainGui.selectData(3, inputInsert, connection);
//            try {
//                Tread = new Thread(new ReadingThread(3, inputInsert -1, connection));
//                Tread.start();
//                Tread.join();
//            } catch (InterruptedException ex) {
//                Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//            }
        }        
        mvstopReadingTime=System.currentTimeMillis();
        mvstopTotalTime = System.currentTimeMillis();
        mvelapsedInsertingTime=mvstopInsertingTime-mvstartInsertingTime;
        mvelapsedReadingTime=(mvstopReadingTime-mvstartReadingTime)/inputNoOfRdTx;
        mvelapsedUpdatingTime=(mvstopUpdatingTime-mvstartUpdatingTime)/inputNoOfVersions;
        mvelapsedTotalTime = mvstopTotalTime-mvstartTotalTime;
        System.out.println("Total Execution time is "+ mvelapsedTotalTime);
        jTable7.getModel().setValueAt(Long.toString(mvelapsedTotalTime), 0, 2);
        jTable7.getModel().setValueAt(Long.toString(mvelapsedInsertingTime), 1, 2);
        jTable7.getModel().setValueAt(Long.toString(mvelapsedUpdatingTime), 2, 2);
        jTable7.getModel().setValueAt(Long.toString(mvelapsedReadingTime), 3, 2);
        
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        inputInsert= Integer.parseInt(jTextField4.getText());
        inputNoOfVersions=Integer.parseInt(jTextField17.getText());
        inputNoOfRdTx=Integer.parseInt(jTextField18.getText());
        Thread Tinsert, Tupdate,Tread;
        startTotalTime=System.currentTimeMillis();
        MainGui mainGui=new MainGui();
        mainGui.establishConnection();
        startInsertingTime=System.currentTimeMillis();
//        Tinsert=new Thread(new InsertThread2(1, inputInsert,connection));
//        Tinsert.start();
//        try {
//            Tinsert.join();
//        } catch (InterruptedException ex) {
//            Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//        }
        mainGui.insertDataMBII(2, inputInsert);
        stopInsertingTime=System.currentTimeMillis();
        startUpdatingTime=System.currentTimeMillis();
//        for(int i=1;i<inputNoOfVersions;i++)
//        {
//            try {
//                Tupdate = new Thread(new UpdateThread1(1,inputInsert,connection));
//                Tupdate.start();
//                Tupdate.join();
//            } catch (InterruptedException ex) {
//                Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//            }
//        }
        for(int i=1;i<inputNoOfVersions;i++){
            mainGui.updateDataMBII(2, inputInsert);
        }
        
        stopUpdatingTime=System.currentTimeMillis();
        startReadingTime=System.currentTimeMillis();
        for(int i=1;i<inputNoOfRdTx;i++)
        {
            mainGui.selectData(3, inputInsert, connection);
//            try {
//                Tread = new Thread(new ReadingThread(3, inputInsert -1, connection));
//                Tread.start();
//                Tread.join();
//            } catch (InterruptedException ex) {
//                Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//            }
        }
        
        stopReadingTime=System.currentTimeMillis();
        stopTotalTime = System.currentTimeMillis();
        elapsedInsertingTime=stopInsertingTime-startInsertingTime;
        elapsedReadingTime=(stopReadingTime-startReadingTime)/inputNoOfRdTx;
        elapsedUpdatingTime=(stopUpdatingTime-startUpdatingTime)/inputNoOfVersions;
        elapsedTotalTime = stopTotalTime - startTotalTime;
        System.out.println("Total Execution time is "+ elapsedTotalTime);
        jTable4.getModel().setValueAt(Long.toString(elapsedTotalTime), 0, 1);
        jTable4.getModel().setValueAt(Long.toString(elapsedInsertingTime), 1, 1);
        jTable4.getModel().setValueAt(Long.toString(elapsedUpdatingTime), 2, 1);
        jTable4.getModel().setValueAt(Long.toString(elapsedReadingTime), 3, 1);
        
        // mvidx try run for testing
        
        
        mvstartTotalTime=System.currentTimeMillis();
        mainGui.establishConnection();
        mvstartInsertingTime=System.currentTimeMillis();
//        Tinsert=new Thread(new InsertThread2(1, inputInsert,connection));
//        Tinsert.start();
//        try {
//            Tinsert.join();
//        } catch (InterruptedException ex) {
//            Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//        }
        mainGui.insertDataMBII(2, inputInsert);
        mvstopInsertingTime=System.currentTimeMillis();
        mvstartUpdatingTime=System.currentTimeMillis();
//        for(int i=1;i<inputNoOfVersions;i++)
//        {
//            try {
//                Tupdate = new Thread(new UpdateThread1(1,inputInsert,connection));
//                Tupdate.start();
//                Tupdate.join();
//            } catch (InterruptedException ex) {
//                Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//            }
//        }
        for(int i=1;i<inputNoOfVersions;i++){
            mainGui.updateDataMBII(2, inputInsert);
        }

        mvstopUpdatingTime=System.currentTimeMillis();
        mvstartReadingTime=System.currentTimeMillis();
        for(int i=1;i<inputNoOfRdTx;i++)
        {
            mainGui.selectData(3, inputInsert, connection);
//            try {
//                Tread = new Thread(new ReadingThread(3, inputInsert -1, connection));
//                Tread.start();
//                Tread.join();
//            } catch (InterruptedException ex) {
//                Logger.getLogger(MainGui.class.getName()).log(Level.SEVERE, null, ex);
//            }
        }
        mvstopReadingTime=System.currentTimeMillis();
        mvstopTotalTime = System.currentTimeMillis();
        mvelapsedInsertingTime=mvstopInsertingTime-mvstartInsertingTime;
        mvelapsedReadingTime=(mvstopReadingTime-mvstartReadingTime)/inputNoOfRdTx;
        mvelapsedUpdatingTime=(mvstopUpdatingTime-mvstartUpdatingTime)/inputNoOfVersions;
        mvelapsedTotalTime = mvstopTotalTime - mvstartTotalTime;
        System.out.println("Total Execution time is "+ mvelapsedTotalTime);
        jTable4.getModel().setValueAt(Long.toString(mvelapsedTotalTime), 0, 2);
        jTable4.getModel().setValueAt(Long.toString(mvelapsedInsertingTime), 1, 2);
        jTable4.getModel().setValueAt(Long.toString(mvelapsedUpdatingTime), 2, 2);
        jTable4.getModel().setValueAt(Long.toString(mvelapsedReadingTime), 3, 2);
        
        
    }//GEN-LAST:event_jButton17ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
     System.exit(0);    
    // TODO add your handling code here:
    }//GEN-LAST:event_jButton12ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainGui.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                
                new MainGui().setVisible(true);
            }
        });
    }

   // String header[]={"Result","Postgresql","MVIDX","Improvement"};
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable4;
    private javax.swing.JTable jTable7;
    private javax.swing.JTextField jTextField17;
    private javax.swing.JTextField jTextField18;
    private javax.swing.JTextField jTextField21;
    private javax.swing.JTextField jTextField22;
    private javax.swing.JTextField jTextField23;
    private javax.swing.JTextField jTextField24;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    // End of variables declaration//GEN-END:variables

    public int inputInsert, inputNoOfVersions,inputNoOfRdTx;
    public long startReadingTime, startInsertingTime, startUpdatingTime, startTotalTime;
    public long stopReadingTime, stopInsertingTime,stopUpdatingTime,stopTotalTime;
    public long elapsedReadingTime, elapsedUpdatingTime, elapsedInsertingTime, elapsedTotalTime;
    public long mvstartReadingTime, mvstartInsertingTime, mvstartUpdatingTime, mvstartTotalTime;
    public long mvstopReadingTime, mvstopInsertingTime,mvstopUpdatingTime,mvstopTotalTime;
    public long mvelapsedReadingTime, mvelapsedUpdatingTime, mvelapsedInsertingTime, mvelapsedTotalTime;
    public void establishConnection() {
        System.out.println("-------- PostgreSQL "
                + "JDBC Connection Testing ------------");

        if (connection != null) {
            return;
        }
        try {
            Class.forName("org.postgresql.Driver");
            connection = DriverManager.getConnection(
                    "jdbc:postgresql://localhost:5432/test", "rohit",
                    "d3fad7d3");
            if (connection != null) {
                System.out.println("Connecting to database...");
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public void closeConnection() {
        try {
            connection.close();
        } catch (Exception e) {
            System.out.println("Problem to close the connection to the database");
        }
    }

    public void startTx() {
        PreparedStatement prep = null;
        try {
            prep = connection.prepareStatement("begin transaction;");
            prep.executeUpdate();
            //System.out.println("begin transaction");
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public void setEnvironment() {
        PreparedStatement prep = null;
        try {
            prep = connection.prepareStatement("set enable_seqscan = off");
            prep.executeUpdate();
            prep = connection.prepareStatement("set enable_bitmapscan = off");
            prep.executeUpdate();
            System.out.println("Environment variable set");
        } catch (Exception e) {
            System.out.println("Problem in setting the environment variables");
        }
    }

    public void endTx() {
        PreparedStatement prep = null;
        try {
            prep = connection.prepareStatement("end transaction;");
            prep.executeUpdate();
           // System.out.println("End transaction");
        } catch (Exception e) {
            System.out.println(e);
        }
    }
    
    public ResultSet selectData(int firstSelect, int lastSelect,Connection c) {
        ResultSet rs = null;
        Statement s = null;
        PreparedStatement prep = null;
        try {
            connection.setAutoCommit(false);
            int id = firstSelect;
            //startTx();
            String selectQuery = "SELECT * FROM emp";
            Statement st = connection.createStatement();
            rs = st.executeQuery(selectQuery);
            //endTx();
            System.out.println("Selection works fine");
            connection.commit();
        } catch (Exception e) {
            System.out.println("Problem in searching the database"+e);
        }
        return rs;
    }

    public PreparedStatement updateDataMBI(int firstUpdate, int lastUpdate) {
        ResultSet rs = null;
        Statement s = null;
        PreparedStatement prep = null;
        
        int valueOfId;
        try {
            connection.setAutoCommit(false);
            for (valueOfId = firstUpdate; valueOfId < lastUpdate; valueOfId++) {
                //startTx();
                String updateSql = "UPDATE emp SET name = 'goyal' where id = " + Integer.toString(valueOfId);
                Statement st = connection.createStatement();
                st.executeUpdate(updateSql);
                //endTx();
            }
            System.out.println("Update works fine");
            connection.commit();
        } catch (Exception e) {
            System.out.println(e);
        }
        return prep;
    }

    public PreparedStatement updateDataMBII(int firstUpdate, int lastUpdate) {
        ResultSet rs = null;
        Statement s = null;
        PreparedStatement prep = null;
        int valueOfId;
        try {
            connection.setAutoCommit(false);
            for (valueOfId = firstUpdate; valueOfId < lastUpdate; valueOfId++) {
                //startTx();
                String updateSql = "UPDATE emp SET name = 'goyal' where id = " + Integer.toString(valueOfId);
                Statement st = connection.createStatement();
                st.executeUpdate(updateSql);
                //endTx();
            }
            System.out.println("Update works fine");
            connection.commit();
        } catch (Exception e) {
            System.out.println("Problem in updating the database");
        }
        return prep;
    }
    
    
    public PreparedStatement insertDataMBI(int firstInsert, int lastInsert) {
        PreparedStatement prep = null;
        int valueOfId;
        try {
            connection.setAutoCommit(false);
            for (valueOfId = firstInsert; valueOfId < lastInsert; valueOfId++) {
                prep = connection.prepareStatement("INSERT INTO emp(name,id) values(?,?);");
                prep.setInt(2, valueOfId);
                prep.setString(1, "rohit");
                prep.executeUpdate();
                // System.out.println("Insertion works fine");
            }
            System.out.println("Insertion works fine");
            connection.commit();
        } catch (Exception e) {
            System.out.println("Problem in inserting the database"+e);
        }
        return prep;
    }
 
    public PreparedStatement insertDataMBII(int firstInsert, int lastInsert) {
        PreparedStatement prep = null;
        int valueOfId;
        try {
            connection.setAutoCommit(false);
            for (valueOfId = firstInsert; valueOfId < lastInsert; valueOfId++) {
                prep = connection.prepareStatement("INSERT INTO emp(name,id) values(?,?);");
                prep.setInt(2, valueOfId);
                prep.setString(1, "rohit");
                prep.executeUpdate();
                if(valueOfId%1000==0)
                {
                    new Thread(new ReadingThread(2, valueOfId, connection)).start();
                }
                // System.out.println("Insertion works fine");
            }
            System.out.println("Insertion works fine");
            connection.commit();
        } catch (Exception e) {
            System.out.println("Problem in inserting the database"+e);
        }
        return prep;
    }
}